package socket.myRPC.rpc;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 单例模式 构建 dispatcher
 * <p>
 * 可以区分 remote 以及 local
 *
 * @author lihh
 */
public class Dispatcher {
  private static Dispatcher dispatcher = null;
  private static final ConcurrentHashMap<String, Object> invokeMap = new ConcurrentHashMap<>();
  
  static {
    dispatcher = new Dispatcher();
  }
  
  private Dispatcher() {
  }
  
  public static Dispatcher create() {
    return dispatcher;
  }
  
  public void register(String k, Object v) {
    invokeMap.put(k, v);
  }
  
  public static Object get(String k) {
    return invokeMap.get(k);
  }
}
